cert-manager安裝
前言
上次開新專案的延伸,
設定domain時,對於cloudflare不夠熟,
還好有個前端同事,熟此門路,因爲他也踩過。
正文
安裝cert-manager
參照官網說明。
下面語法不一定是最新的
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.3/cert-manager.yaml
再來就是建立 ClusterIssuer
跟 Certificate
在此之前,要先到cloudflare產生一組token,
才有權限對這個domain做驗證。
我的domain是在cloud domain購買,然後再cloudflare託管。
為什麼不直接在google cloud託管,我也不知道,之前就這樣了。
User Profile > API Tokens > API Tokens.
參照官方文件,設定權限,取得token
將token存到 secret
apiVersion: v1
kind: Secret
metadata:
name: cloudflare-api-token-ezio-com
namespace: cert-manager
type: Opaque
stringData:
api-token: <token>
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: cloudflare-issuer-ezio-com
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: cloudflare-issuer-ezio-com
solvers:
- dns01:
cloudflare:
email: ezio@abc.com
apiTokenSecretRef:
name: cloudflare-api-token-ezio-com
key: api-token
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: ezio-com-tls
namespace: istio-system
spec:
secretName: ezio-com-tls
issuerRef:
name: cloudflare-issuer-ezio-com
kind: ClusterIssuer
commonName: "*.ezio.com"
dnsNames:
- "*.ezio.com"
這邊注意一下,檔案之間的關聯性。
上面寫的範例domain是 *.ezio.com
,請改爲自己實際使用的。
部署上去後,檢查狀態,有沒有Ready,通常不會超過5分鐘。
kubectl get certificate -A
如果啓動失敗的話,使用下面指令檢查log
kubectl describe certificate ezio-com-tls
如果是下面這個失敗訊息,
Found no Zones for domain _acme-challenge.aplusmanagex.com. (neither in the sub-domain nor in the SLD) please make sure your domain-entries in the config are correct and the API key is correctly setup with Zone.read rights.
表示你的token沒有相關權限,這個坑我踩完了orz。
ref.